﻿using Huasky.MyWrod.Web.Core.Auth;

namespace Huasky.MyWrod.Web.Core.Extensions;

public static class AuthEx
{
    public static void AddHuaskyAuth(this IServiceCollection services)
    {
        services.AddAuthentication(options =>
        {
            options.AddScheme<AuthHandler>(AuthHandler.SchemeName, "default scheme");
            options.DefaultAuthenticateScheme = AuthHandler.SchemeName;
            options.DefaultChallengeScheme = AuthHandler.SchemeName;
        });
    }

    public static void UseHuaskyAuth(this WebApplication app)
    {
        // 认证
        app.UseAuthentication();
        // 授权
        app.UseAuthorization();
    }
}
